package com.dayangxiaoen.pms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dayangxiaoen.pms.mapper.ExchangeWayMapper;
import com.dayangxiaoen.pms.po.ExchangeWay;
import com.dayangxiaoen.pms.po.SalesVolume;
import com.dayangxiaoen.pms.service.ExchangeWayService;
import com.dayangxiaoen.pms.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.util.List;

/**
 * @author dayangxiaoen
 */
@Service
public class ExchangeWayServiceImp extends ServiceImpl<ExchangeWayMapper,ExchangeWay> implements ExchangeWayService {

    @Autowired
    private ExchangeWayMapper exchangeWayMapper;

    @Override
    public Result findExchangeByDays(int days) {
        LocalDate now = LocalDate.now();

        LambdaQueryWrapper<ExchangeWay> wrapper = new LambdaQueryWrapper<ExchangeWay>();
        wrapper.eq(ExchangeWay::getDate,now);
        wrapper.eq(ExchangeWay::getDays,days);

        List<ExchangeWay> exchangeWays = exchangeWayMapper.selectList(wrapper);

        return Result.sucess(exchangeWays,"获取销售量成功");
    }
}
